package com.hyh.toyshopping.mapper;


import com.hyh.toyshopping.model.OrderDesc;
import com.hyh.toyshopping.model.Orders;
import com.hyh.toyshopping.model.view.OrderDescView;
import com.hyh.toyshopping.model.view.OrderView;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @version 1.0
 * @BelongsProject:IntelliJ IDEA
 * @BelongsPackage:com.hyh.myshopping.mapper
 * @Author:hyhWTX
 * @ClassName:OrderMapper
 * @CreateTime:2022年-12月-12日 16:36
 * @Description: TODO (一句话描述以下该类的功能)
 */
@Repository
public interface OrderMapper {
    /**
     * 向tbl_order中添加订单
     * @param orders
     */
    @Insert("insert into tbl_order values(#{order_id},#{user_id},#{order_to_name},#{order_to_address},#{order_to_phone},now(),default,#{order_total_price})")
    void addOrder(Orders orders);

    void addOrderDesc(@Param("orderDescs") List<OrderDesc> orderDescs);


    @Select("select * from tbl_order where user_id = #{user_id}")
    List<Orders> getOrderByUser(int user_id);

    List<OrderDescView> getOrderDescByOrderId(String order_id);

    List<OrderView> getOrderList();

    @Update("update tbl_order set order_status=#{order_status} where order_id=#{order_id}")
    void updateOrderStatus(@Param("order_id") String order_id, @Param("order_status") int order_status);
}
